package com.briup.dao.impl;

import org.apache.ibatis.session.SqlSession;

import com.briup.bean.User;
import com.briup.dao.*;
import com.briup.util.DBTool;


public class IUserDaoImpl implements IUserDao{

	@Override
	public void saveUser(User user) {
		SqlSession sqlSession = DBTool.getSession();
		
		sqlSession.insert("s_user.insetOne", user);
		sqlSession.commit();
		sqlSession.close();
	}
	
	@Override
	public User findUserByName(String name) {
		User user = new User();
		SqlSession sqlSession = DBTool.getSession();
		
		user = sqlSession.selectOne("s_user.selectOneByUsername", name);
		sqlSession.commit();
		sqlSession.close();
		
		return user;
	}

	@Override
	public void updateUser(User user) {
		SqlSession sqlSession = DBTool.getSession();
		
		sqlSession.update("s_user.updateOne", user);
		sqlSession.commit();
		sqlSession.close();
	}

}
